﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Air_condition.DO
{
    [Serializable]
    public class Construction
    {
        // Attributes of construction object and child objects
        public string sname;
        public int istructure = -1;
        public int icharacteristics = -1;
        public double dbarea;
        public double dbwidth;
        public double dblength;
        public double dbheatTransferCoefficient;
        public double dbtemperatureDiff;

        // Public access to attributes
        public int iStructure
        {
            get { return istructure; }
            set { istructure = value; }
        }

        public int iCharacteristics
        {
            get { return icharacteristics; }
            set { icharacteristics = value; }
        }

        public string sName
        {
            get { return sname; }
            set { sname = value; }
        }

        public double dbArea
        {
            get { return dbarea; }
            set { dbarea = value; }
        }

        public double dbWidth
        {
            get { return dbwidth; }
            set { dbwidth = value; }
        }

        public double dbLength
        {
            get { return dblength; }
            set { dblength = value; }
        }

        public double dbHeatTransferCoefficient
        {
            get { return dbheatTransferCoefficient; }
            set { dbheatTransferCoefficient = value; }
        }

        public double dbTemperatureDiff
        {
            get { return dbtemperatureDiff; }
            set { dbtemperatureDiff = value; }
        }

        //  Tính hiệu nhiệt độ dư
        /// <summary>
        /// Calculate temperature different (delta T) 
        /// </summary>
        /// <param name="dbinsideRoomTemp">inside room temperature</param>
        /// <param name="dboutsideRoomTemp">outside room temperature</param>
        public virtual void CalculateTemperatureDiff(double dbinsideRoomTemp, double dboutsideRoomTemp)
        {
            dbtemperatureDiff = dboutsideRoomTemp - dbinsideRoomTemp;
        }

        // Tính truyền nhiệt qua kết cấu bao che Q2 bao gồm wall, ceilling, floor.
        /// <summary>
        /// Calculate heat transfer through construction (Q2) 
        /// </summary>
        /// <param name="dbinsideRoomTemp">inside room temperature</param>
        /// <param name="dboutsideRoomTemp">outside room temperature</param>
        /// <returns>heat transfer through construction (double number)</returns>
        public virtual double CalculateConstructionHeatTransfer(double dbinsideRoomTemp, double dboutsideRoomTemp)
        {
            CalculateTemperatureDiff(dbinsideRoomTemp, dboutsideRoomTemp);
            dbarea = dbWidth * dblength;
            return dbarea * dbheatTransferCoefficient * dbtemperatureDiff;
        }
    }
}
